home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000061_icon-group-sender _Wed Sep 10 14:23:39 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Wed, 10 Sep 1997 14:23:38 -0500 (EST)
  3. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  4.     id AA31626; Wed, 10 Sep 1997 12:23:37 -0700
  5. To: icon-group
  6. Date: Wed, 10 Sep 1997 13:59:41 GMT
  7. From: ltest@rte9-sun_5.5.1 (news_check.py)
  8. Message-Id: <5v69d2$4su@lztnsc06.att.com>
  9. Organization: AT&T WorldNet Load Test
  10. Sender: icon-group-request
  11. References: <Stuart.Robinson-0209972348010001@asianstmg-221.anu.edu.au>
  12. Subject: Re: More specific GREP-related question
  13. Errors-To: icon-group-errors
  14. Status: RO
  15.  
  16. In article <5uh7b5$gd7@news-central.tiac.net> mike@stok.co.uk (Mike Stok) wrote:
  17. > In article <Stuart.Robinson-0209972348010001@asianstmg-221.anu.edu.au>,
  18. > Stuart Robinson <Stuart.Robinson@anu.edu.au> wrote:
  19. > >Does anyone know how regular expressions like [a-z] work when a
  20.  
  21. In article <Stuart.Robinson-0209972348010001@asianstmg-221.anu.edu.au>,
  22. Stuart Robinson <Stuart.Robinson@anu.edu.au> wrote:
  23. >Does anyone know how regular expressions like [a-z] work when a
  24. >non-alphanumeric character is used?  For example, which characters would
  25. >the following regular expression match?
  26. >
  27. >[1-!]
  28.  
  29. If you actually use that in a regex on a system with ASCII encoding (or 
  30. one of the character sets wherer the low 128 characters are ASCII) you
  31. should get an "invalid [] range in regexp" warning as perl likes to work
  32. with ascending ranges.  In ASCII you're asking for a range from character
  33. 49 up to character 33
  34.  
  35. >What about this one?
  36. >
  37. >[a-1]
  38. >
  39. >And the reverse?
  40. >
  41. >[1-a]
  42.  
  43. 1-a will match a character in the range characters 49 to 97 inclusive, so
  44. in the debugger I can use perl's ord and chr functions to see what
  45. characters are in that range:
  46.  
  47.   DB<1> print ord '1'
  48. 49
  49.   DB<2> print ord 'a'
  50. 97
  51.   DB<3> print map {chr $_} (49 .. 97)
  52. 123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a
  53.  
  54. >I'm sure all of this could be predicted if one had knowledge of the
  55. >ordering of ASCII, but I'm afraid I lack such knowledge.  Any tips? 
  56.  
  57. If you're on a unix system then there is usually a manual page for ascii,
  58. so
  59.  
  60.   man ascii
  61.  
  62. should get you a useful page.  Failing that a www search or a reference
  63. book might have a table of ascii codes in it (printer manuals usually have
  64. tables of characters somewhere in them...)
  65.  
  66. Hope this helps,
  67.  
  68. Mike
  69. -- 
  70. mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
  71. http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
  72. http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
  73. stok@psa.pencom.com                |      Pencom Systems Administration (work)
  74.